package com.neo.impatient.C08_extends.C08_06_OverFiled

class Person(val name: String) {

  override def toString: String = s"${getClass.getName}[name=$name]"

}


//覆写字段或者方法
class SecretAgent(codename: String) extends Person(codename){
  override val name = "secrte" //不暴露姓名

  override def toString = "secrte"  //或者类名字
}

object Person{

  def main(args: Array[String]): Unit = {
    val pp = new Person("zhao")
    println(pp)
  }
}


/**
  *1. def只能重写另一个def
  *2. val只能重写另外一个val,或者不带参数的def
  *3. var只能重写另外一个抽象的var
  */